#%RAML 0.8

---
title: SLL Service Catalogue GUI support service
version: 1.0
baseUri: http://localhost:8080/gui
documentation:
  - title: General API information
    content: TODO! Description of the GUI Service Functions
protocols: [HTTP,HTTPS]

schemas:
  - capacity: !include schema/capacity.json
  - capacityList: !include schema/capacityList.json
  - careUnitReference: !include schema/careUnitReference.json
  - careUnitReferenceList: !include schema/careUnitReferenceList.json
  - codeSystemCode: !include schema/codeSystemCode.json
  - codeSystemCodeList: !include schema/codeSystemCodeList.json
  - idmap: !include schema/idmap.json
  - idmapList: !include schema/idmapList.json
  - monitorInfo: !include schema/monitorInfo.json
  - product: !include schema/productType.json
  - productType: !include schema/productType.json
  - productTypeList: !include schema/productTypeList.json
  - productReference: !include schema/productReference.json
  - productReferenceList: !include schema/productReferenceList.json
  - productsByUnit: !include schema/productsByUnit.json
  - productsByUnitList: !include schema/productsByUnitList.json
  - roleInfo: !include schema/roleInfo.json
  - roleInfoList: !include schema/roleInfoList.json
  - user: !include schema/user.json
  - userList: !include schema/userList.json
  - userCreate: !include schema/userCreate.json
  - userAddToUnit: !include schema/userAddToUnit.json
  - unit: !include schema/unit.json
  - unitList: !include schema/unitList.json
  - unitName: !include schema/unitNameList.json
  - unitNameList: !include schema/unitNameList.json
  - stringList: !include schema/stringList.json

/aggregated:
  description: Aggredated service for fetching information from any of the underlying base information services
  displayName: AggregatedService
  /test:
    get:
      description: Some sort of test service that just throws an exception. Unknown if it is currently in use.
  /capacity/{hsaID}:
    get:
    # displayName: findCapacityByHsaID
      description: Lists all capacity information for a specific care unit HSA Id.
      responses:
        200:
          description: The requested capacity information was found and is returned in the body.
          body:
            application/json:
              schema: productsByUnitList
              example : |
                [
                  {
                    "hsaID": "SE2321000016-3TNL",
                    "name": "Namn",
                    "products": [
                      {
                        "id": "SE2321000016-1HF3",
                        "name": "40",
                        "capacity": [
                          {
                            "codeSystem": "oid.sll.vantetider",
                            "code": "2",
                            "displayName": "Namnet",
                            "value": "4",
                            "validTo": 1425410281000
                          },
                          {
                            "codeSystem": "oid.sll.vantetider",
                            "code": "2",
                            "displayName": "Namnet",
                            "value": "4",
                            "validTo": 1425410281000
                          }
                        ]
                      }
                    ]
                  }
                ]
  /capacity/byunitids:
    post:
      # displayName: findCapacityByUnitIds
        description: Lists all the capacity information for the provided list of unit id:s
        body:
          application/json:
            schema: unitNameList
            example: |
              {
                "units" :
                  [
                    {"unitId": "SE2321000016-4ZRK"},
                    {"unitId": "SE2321000016-G82R"}
                  ]
              }
        responses:
          200:
            description: The requested capacity information was found and is returned in the body.
            body:
              application/json:
                schema: productsByUnitList
                example : |
                  [
                    {
                      "hsaID": "SE2321000016-3TNL",
                      "name": "Namn",
                      "products": [
                        {
                          "id": "SE2321000016-1HF3",
                          "name": "40",
                          "capacity": [
                            {
                              "codeSystem": "oid.sll.vantetider",
                              "code": "2",
                              "displayName": "Namnet",
                              "value": "4",
                              "validTo": 1425410281000
                            },
                            {
                              "codeSystem": "oid.sll.vantetider",
                              "code": "2",
                              "displayName": "Namnet",
                              "value": "4",
                              "validTo": 1425410281000
                            }
                          ]
                        }
                      ]
                    }
                  ]
  /units:
    get:
    # displayName: readOffers
      description: TODO - Ta bort!
      responses:
        200:
          description: The requested unit information was found and is returned in the body.
          body:
            application/json:
              schema: unitList
              example : |
                [
                  {
                    "creationTime": 1393305699000,
                    "productReferences": [
                      {
                        "capacities": [],
                        "comment": null,
                        "contractedPrice": null,
                        "contractedProduct": false,
                        "product": {
                            "codes": [],
                            "creationTime": null,
                            "description": null,
                            "displayName": null,
                            "name": "5",
                            "status": null,
                            "updateTime": null,
                            "updatedByHsaid": null
                        }
                      }
                    ],
                    "regionalUnitId": "SE2321000016-4ZRK",
                    "relativeDistinguishedName": null,
                    "unitId": "SE2321000016-4ZRK",
                    "updateTime": 1425911569000
                  }
                ]
  /unit/{hsaId}:
    uriParameters:
      hsaId:
        displayName: The Hsa-id for the care unit to list offer information for
        type: string
    get:
    # displayName: readOffer
      description: Reads information for a specific Care Unit HSA Id
      responses:
        200:
          description: The requested unit information was found and is returned in the body.
          body:
            application/json:
              schema: unitList
              example : |
                [
                  {
                    "creationTime": 1393305699000,
                    "productReferences": [
                      {
                        "capacities": [],
                        "comment": null,
                        "contractedPrice": null,
                        "contractedProduct": false,
                        "product": {
                            "codes": [],
                            "creationTime": null,
                            "description": null,
                            "displayName": null,
                            "name": "5",
                            "status": null,
                            "updateTime": null,
                            "updatedByHsaid": null
                        }
                      }
                    ],
                    "regionalUnitId": "SE2321000016-4ZRK",
                    "relativeDistinguishedName": null,
                    "unitId": "SE2321000016-4ZRK",
                    "updateTime": 1425911569000
                  }
                ]
  /idmap:
    get:
    # displayName: getIdmap
      description: Reads the entire current Id map
      responses:
        200:
          description: The requested Id map was found and is returned in the body.
          body:
            application/json:
              schema: idmapList
              example : |
                [
                  {
                    "hsaId": "SE2321000016-4ZRK",
                    "ekId": "213F3343342",
                    "hsaRelativeDistinguishedName": "",
                    "vmId": "34234",
                    "vmCareGiverPartId": "SE2321000016-4Y9X",
                    "vmCareGiverName": "SLSO",
                    "vmCareGiverPartName": "SL",
                    "kombika": "2351223L01",
                    "sklId": "VG14141121",
                    "allowExport": false,
                    "allowImport": false
                  }
                ]

/monitor:
  displayName: MonitorService
  description: Handles monitoring of service status
  get:
  # displayName: getMonitorData
    description: Reads the current monitor status
    responses:
      200:
        description: The requested Id map was found and is returned in the body.
        body:
          application/json:
            schema: monitorInfo
            example : |
              {
                "vmImportFileTimeStamp": "Feb 23, 2014 8:00:01 PM",
                "vmImportNumCapacities": "4893",
                "vmImportNumIdmap": "416",
                "vmImportNumOffers": "488",
                "vmImportNumProducts": "166",
                "vmImportTimeStamp": "20140224072356"
              }

/roles:
  displayName: RolesService
  description: Handles information of different user roles
  get:
  # displayName: find
    description: Reads the current availible user roles.
    responses:
      200:
        description: The requested Role was found and is returned in the body.
        body:
          application/json:
            schema: roleInfoList
            example : |
              [
                {"role":"SUPERADMIN"},
                {"role":"CAREUNITADMIN"},
                {"role":"CAPACITYADMIN"}
              ]
/users:
  displayName: UsersService
  description: Handles information of different users
  get:
  # displayName: find
    description: Get all users. NOTE - careUnit is not returned
    responses:
      200:
        description: The requested User was found and is returned in the body.
        body:
          application/json:
            schema: userList
            example : |
              [
                {
                  "careUnits": [],
                  "createdByHsaId": "",
                  "creationTime": 1391636105000,
                  "email": "",
                  "hsaId": "super",
                  "lastLogin": 1428666138000,
                  "realname": "super",
                  "role": "SUPERADMIN",
                  "sourceSystemHsaId": "",
                  "status": "ACTIVE",
                  "updatedTime": 1391636105000
                },
                {
                  "careUnits": [],
                  "createdByHsaId": "",
                  "creationTime": 1399452714000,
                  "email": "ca@sll.se",
                  "hsaId": "ca",
                  "lastLogin": null,
                  "realname": "Capacity Admin",
                  "role": "CAPACITYADMIN",
                  "sourceSystemHsaId": "",
                  "status": "ACTIVE",
                  "updatedTime": 1399452714000
                }
              ]
  post:
  # displayName: createUser
    description: Create a new User
    body:
      application/json:
        schema: userCreate
        example: |
          {
            "status": "OPEN",
            "hsaId": "SE2321000016-FHR3",
            "realname": "Bosse Bäckström",
            "email": "bosse.backstrom@bockling.nu",
            "hsaID": "SE2321000016-FHR3",
            "password": "********",
            "role": "Vaktmästare",
            "careUnitID":
            [
              {
                "hsaId": "SE2321000016-45FD",
                "displayName": "Enhet X"
              }
            ]
          }
    responses:
      201:
        description: The requested User was successfully created and is returned in the body
        body:
          application/json:
            schema: user
            example: |
              {
                "careUnits": [],
                "createdByHsaId": "",
                "creationTime": 1391636105000,
                "email": "",
                "hsaId": "super",
                "lastLogin": 1428666138000,
                "realname": "super",
                "role": "SUPERADMIN",
                "sourceSystemHsaId": "",
                "status": "ACTIVE",
                "updatedTime": 1391636105000
              }
  /{hsaId}:
    uriParameters:
      hsaId:
        displayName: The Hsa-id for the User
        type: string
    get:
    # displayName: getUser
      description: Get a specific User
      responses:
        200:
          description: The requested User was found and is returned in the body.
          body:
            application/json:
              schema: user
              example : |
                {
                  "careUnits": [],
                  "createdByHsaId": "",
                  "creationTime": 1391636105000,
                  "email": "",
                  "hsaId": "super",
                  "lastLogin": 1428666138000,
                  "realname": "super",
                  "role": "SUPERADMIN",
                  "sourceSystemHsaId": "",
                  "status": "ACTIVE",
                  "updatedTime": 1391636105000
                }
    put:
    # displayname: updateUser
      description: Update the information for a specific user.
      body:
        application/json:
          schema: userCreate
          example: |
            {
              "status": "OPEN",
              "hsaId": "SE2321000016-FHR3",
              "realname": "Bosse Bäckström",
              "email": "bosse.backstrom@bockling.nu",
              "hsaID": "SE2321000016-FHR3",
              "password": "********",
              "role": "Vaktmästare",
              "careUnitID":
              [
                {
                  "hsaId": "SE2321000016-45FD",
                  "displayName": "Enhet X"
                }
              ]
            }
      responses:
        200:
          description: The user was updated and the new User object is returned in the Body
          body:
            application/json:
              schema: user
              example: |
                {
                  "careUnits": [],
                  "createdByHsaId": "",
                  "creationTime": 1391636105000,
                  "email": "",
                  "hsaId": "super",
                  "lastLogin": 1428666138000,
                  "realname": "super",
                  "role": "SUPERADMIN",
                  "sourceSystemHsaId": "",
                  "status": "ACTIVE",
                  "updatedTime": 1391636105000
                }
    delete:
      description: Delete an offer
      responses:
        204:
          description: Offer was deleted successfully (no content in response body)
    /role/{role}:
      uriParameters:
        role:
          displayName: The name of the user role
          type: string
      put:
      # displayName: updateRole
        description: Updates the role for a specific user
        responses:
          204:
            description: The Role was updated. No content in response.
  /units/{unitId}:
    uriParameters:
      unitId:
        displayName: The unit id
        type: string
    get:
    # displayName: findUsersForUnit
      description: Get all users for the given unit
      responses:
        200:
          description: The user information was found and is returned in the body.
          body:
            application/json:
              schema: userList
              example: |
                [
                  {
                    "careUnits": [],
                    "createdByHsaId": "",
                    "creationTime": 1391636105000,
                    "email": "",
                    "hsaId": "super",
                    "lastLogin": 1428666138000,
                    "realname": "super",
                    "role": "SUPERADMIN",
                    "sourceSystemHsaId": "",
                    "status": "ACTIVE",
                    "updatedTime": 1391636105000
                  },
                  {
                    "careUnits": [],
                    "createdByHsaId": "",
                    "creationTime": 1399452714000,
                    "email": "ca@sll.se",
                    "hsaId": "ca",
                    "lastLogin": null,
                    "realname": "Capacity Admin",
                    "role": "CAPACITYADMIN",
                    "sourceSystemHsaId": "",
                    "status": "ACTIVE",
                    "updatedTime": 1399452714000
                  }
                ]
  /units/setusers:
    put:
    # displayName: setUsersForUnit
      description: Sets user for the specified unit.
      body:
        application/json:
          schema: userAddToUnit
          example: |
            {
              "unitId": "1111AFAF1",
              "hsaId": "SE2321000016-TDDR"
            }
      responses:
        204:
          description: The user information was successfully updated.
  /emails:
    post:
    # findAdminEmails
      description: Finds email addresses for administrators for the given units. This method will return emails for users with roles CAREUNITADMIN and CAPACITYADMIN.
      body:
        application/json:
          schema: |
            {
              "$schema": "http://json-schema.org/draft-03/schema",
              "type": "array",
              "description": "a collection of Users",
              "items": { "type": "string"}
            }
          example: |
            [
              "Unit 1",
              "Unit 2"
            ]
      responses:
        200:
          body:
            application/json:
              schema: |
                {
                  "$schema": "http://json-schema.org/draft-03/schema",
                  "type": "array",
                  "description": "a collection of Users",
                  "items": { "type": "string"}
                }
              example: |
                [
                  "bosse.backstrom@bockling.nu",
                  "adam.andersson@amail.as"
                ]